package com.fausto.learnimprint.message.consumer

import com.fausto.learnimprint.core.mapper.BlogMapper
import com.fausto.learnimprint.message.MqConstant
import org.springframework.amqp.rabbit.annotation.RabbitHandler
import org.springframework.amqp.rabbit.annotation.RabbitListener
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component

@Component
@RabbitListener(queues = [MqConstant.BLOG_QUEUE])
class BlogListener {

    @Autowired
    lateinit var blogMapper: BlogMapper

    @RabbitHandler
    fun updateBlog(blog: com.fausto.learnimprint.core.model.entity.Blog){
        blogMapper.updateById(blog)
    }
}